Skip to contentSkip to conversation

bitbake-setup: Avoid unexpected positional parameter propagation when sourcing scripts

PATCH Superseded [email protected] 2 participants 3 messages Nov 25, 2025

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bitbake-setup: Avoid unexpected positional parameter propagation when sourcing scripts

From: Changqing Li <[email protected]>

Using set to define positional parameters in the current shell causes those parameters to persist. When another script is sourced in the same shell without explicit arguments, it unexpectedly inherits these positional parameters. This change prevents such unintended propagation.

---
 bin/bitbake-setup | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
bin/bitbake-setup +1 -1
index 75be90940..7f77bda55 100755
@@ -184,7 +184,7 @@ def setup_bitbake_build(bitbake_config, layerdir, setupdir, thisdir, update_bb_c
 
     def _make_init_build_env(builddir, oeinitbuildenvdir):
         builddir = os.path.realpath(builddir)
-        cmd = "cd {}\nset {}\n. ./oe-init-build-env\n".format(oeinitbuildenvdir, builddir)
+        cmd = "cd {}\n. ./oe-init-build-env {}\n".format(oeinitbuildenvdir, builddir)
         initbuild_in_builddir = os.path.join(builddir, 'init-build-env')
 
         with open(initbuild_in_builddir, 'w') as f:
Signature · 1 line
2.34.1
#1 lore raw
Quoted 19 lines · Changqing Li via lists.openembedded.org

From: Changqing Li <[email protected]>

Using set to define positional parameters in the current shell causes those parameters to persist. When another script is sourced in the same shell without explicit arguments, it unexpectedly inherits these positional parameters. This change prevents such unintended propagation.

---
 bin/bitbake-setup | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
bin/bitbake-setup +0 -0
index 75be90940..7f77bda55 100755
@@ -184,7 +184,7 @@ def setup_bitbake_build(bitbake_config, layerdir,

setupdir, thisdir, update_bb_c

Quoted 7 lines

def _make_init_build_env(builddir, oeinitbuildenvdir):
builddir = os.path.realpath(builddir)
- cmd = "cd {}\nset {}\n.
./oe-init-build-env\n".format(oeinitbuildenvdir, builddir)
+ cmd = "cd {}\n. ./oe-init-build-env
{}\n".format(oeinitbuildenvdir, builddir)

Sadly, dash does not support this (I used "set {}", to enable its support). Maybe use "set --" to remove any added positional argument? That seem to work:

 $ dash
$ set A
$ echo $1
A
$ set --
$ echo $1

$

Regards,

Quoted 18 lines

initbuild_in_builddir = os.path.join(builddir, 'init-build-env')

with open(initbuild_in_builddir, 'w') as f:
--
2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#18487):
https://lists.openembedded.org/g/bitbake-devel/message/18487
Mute This Topic: https://lists.openembedded.org/mt/116465767/4316185
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Signature · 2 lines
Yoann Congal
Smile ECS
#2 lore raw
Quoted 37 lines · Yoann Congal

**
*CAUTION: This email comes from a non Wind River email account!*
Do not click links or open attachments unless you recognize the sender and know the content is safe.

Le mar. 25 nov. 2025 à 08:34, Changqing Li via lists.openembedded.org <https://urldefense.com/v3/__http://lists.openembedded.org__;!!AjveYdw8EvQ!fu8ZgVhqx6-gTH5HK3ploud4sYOeN07Y-QBQseosoDoeG7EdjNhWwwBCGKqQXh-mZhMOXASG8P90qiwYdFZ_AXlO84kBcw$> <changqing.li <https://urldefense.com/v3/__http://changqing.li__;!!AjveYdw8EvQ!fu8ZgVhqx6-gTH5HK3ploud4sYOeN07Y-QBQseosoDoeG7EdjNhWwwBCGKqQXh-mZhMOXASG8P90qiwYdFZ_AXn9tMDYxw$>[email protected]> a écrit :

From: Changqing Li <[email protected]>

Using set to define positional parameters in the current shell causes
those parameters to persist. When another script is sourced in the same
shell without explicit arguments, it unexpectedly inherits these positional parameters. This change prevents such unintended propagation.

---
 bin/bitbake-setup | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/bitbake-setup b/bin/bitbake-setup index 75be90940..7f77bda55 100755
--- a/bin/bitbake-setup
+++ b/bin/bitbake-setup
@@ -184,7 +184,7 @@ def setup_bitbake_build(bitbake_config, layerdir, setupdir, thisdir, update_bb_c

     def _make_init_build_env(builddir, oeinitbuildenvdir):
         builddir = os.path.realpath(builddir)
-        cmd = "cd {}\nset {}\n. ./oe-init-build-env\n".format(oeinitbuildenvdir, builddir) +        cmd = "cd {}\n. ./oe-init-build-env {}\n".format(oeinitbuildenvdir, builddir)

Quoted 8 lines

Sadly, dash does not support this (I used "set {}", to enable its support). Maybe use "set --" to remove any added positional argument? That seem to work:

 $ dash
$ set A
$ echo $1
A
$ set --
$ echo $1

Thanks,  I will update with a V2 patch.

//Changqing

Quoted 33 lines

$

Regards,

             initbuild_in_builddir = os.path.join(builddir,
    'init-build-env')

             with open(initbuild_in_builddir, 'w') as f:
    -- 
    2.34.1


    -=-=-=-=-=-=-=-=-=-=-=-
    Links: You receive all messages sent to this group.
    View/Reply Online (#18487):
    https://lists.openembedded.org/g/bitbake-devel/message/18487
    <https://urldefense.com/v3/__https://lists.openembedded.org/g/bitbake-devel/message/18487__;!!AjveYdw8EvQ!fu8ZgVhqx6-gTH5HK3ploud4sYOeN07Y-QBQseosoDoeG7EdjNhWwwBCGKqQXh-mZhMOXASG8P90qiwYdFZ_AXnBZyZ1XA$>
    Mute This Topic:
    https://lists.openembedded.org/mt/116465767/4316185
    <https://urldefense.com/v3/__https://lists.openembedded.org/mt/116465767/4316185__;!!AjveYdw8EvQ!fu8ZgVhqx6-gTH5HK3ploud4sYOeN07Y-QBQseosoDoeG7EdjNhWwwBCGKqQXh-mZhMOXASG8P90qiwYdFZ_AXnpWepkjA$>
    Group Owner: [email protected]
    <mailto:bitbake-devel%[email protected]>
    Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub
    <https://urldefense.com/v3/__https://lists.openembedded.org/g/bitbake-devel/unsub__;!!AjveYdw8EvQ!fu8ZgVhqx6-gTH5HK3ploud4sYOeN07Y-QBQseosoDoeG7EdjNhWwwBCGKqQXh-mZhMOXASG8P90qiwYdFZ_AXkFZYk5mQ$>
    [[email protected]]
    -=-=-=-=-=-=-=-=-=-=-=-
Signature · 2 lines
Yoann Congal
Smile ECS